home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / java_eoe.idb / usr / java / bin / .java_wrapper.z / .java_wrapper
Encoding:
Korn shell script  |  2000-05-20  |  5.9 KB  |  227 lines

  1. #! /bin/ksh -p
  2. #
  3. #     @(#)java_wrapper.sh    1.35 98/12/23
  4. #
  5. #===================================================================
  6. # THIS SCRIPT AND JAVA WILL NOT RUN UNDER SUNOS4.X, AKA SOLARIS 1.X.  
  7. #===================================================================
  8.  
  9. set +u
  10.  
  11. function path_warn {
  12.   echo "Warning -- $2 not consistent with the Java home location."
  13.   echo $2 is: $1
  14.   echo JAVA_HOME is: $JAVA_HOME
  15.   if [[ $2 = CLASSPATH ]]
  16.   then
  17.    echo "We recommend not putting any system classes into CLASSPATH."
  18.    echo "(The java invocation script will add these in the correct place.)"
  19.   else
  20.     if [[ $2 = LD_LIBRARY_PATH ]]
  21.     then
  22.      echo "We recommend not putting any system libraries into LD_LIBRARY_PATH."
  23.      echo "(The java invocation script will add these in the correct place.)" 
  24.      else
  25.       if [[ $2 = LD_LIBRARYN32_PATH ]]
  26.       then
  27.        echo "We recommend not putting any system libraries into LD_LIBRARYN32_PATH."
  28.        echo "(The java invocation script will add these in the correct place.)"
  29.       fi
  30.     fi
  31.   fi
  32. }
  33.  
  34. function check_path {
  35.   if egrep -s '^/usr/java/|:/usr/java/' << EOF
  36. $1
  37. EOF
  38.   then
  39.     if ! egrep -s '^/usr/java$|^/usr/java/' << EOF
  40. $JAVA_HOME
  41. EOF
  42.     then
  43.       # CLASSPATH/LD_LIBRARY_PATH/LD_LIBRARYN32_PATH 
  44.       # has components from /usr/java, but
  45.       # java components are not being taken from /usr/java.
  46.       path_warn $1 $2
  47.     fi
  48.   else
  49.     if egrep -s /usr/java/ << EOF
  50. $1
  51. EOF
  52.     then
  53.       if egrep -s '^/usr/java$|^/usr/java/' << EOF
  54. $JAVA_HOME
  55. EOF
  56.       then
  57.         # CLASSPATH/LD_LIBRARY_PATH/LD_LIBRARYN32_PATH 
  58.         # has components from /usr/java under an
  59.     # alternate root, but java components are being taken from /usr/java.
  60.         path_warn $1 $2
  61.       fi
  62.     fi
  63.   fi
  64. }
  65.  
  66. # Set up default variable values if not supplied by the user.
  67.  
  68. PRG=`whence $0` >/dev/null 2>&1
  69. J_HOME=`/usr/bin/dirname $PRG`/..
  70. progname=`/usr/bin/basename $0`
  71.  
  72.  
  73. # The default ABI is n32, unless the SGI_ABI environment variable
  74. # indicates otherwise.
  75.  
  76. if [[ $SGI_ABI = -32 ]]
  77. then
  78.   export JAVA_N32=0
  79. elif [[ $SGI_ABI = -o32 ]]
  80. then
  81.   export JAVA_N32=0
  82. else
  83.   export JAVA_N32=1
  84. fi
  85.  
  86. # The default THREADS_TYPE is "green_threads".  To change the default change
  87. # the setting of the DEFAULT_THREADS_FLAG variable.  The only valid values 
  88. # of that variable are 'green' and 'native'. 
  89. # This introduces a dependency of this wrapper on the policy used to do builds.
  90. # e.g. the usage of the name "green_threads" here is dependent on the build
  91. # scripts which use the same name. Since this is somewhat analogous to the
  92. # wrapper already depending on the build scripts putting the executable in
  93. # a specific place (JAVA_HOME/bin/sgi), the new dependency does not
  94. # seem all that bad.
  95.  
  96. DEFAULT_THREADS_FLAG=green
  97.  
  98. if [[ ${THREADS_FLAG:-${DEFAULT_THREADS_FLAG}} = native ]] ; then 
  99.     THREADS_TYPE=native_threads
  100. else
  101.     THREADS_TYPE=green_threads
  102. fi
  103. export THREADS_TYPE
  104. #echo "Using executables built for $THREADS_TYPE"
  105.  
  106. #
  107. # If any combination of -32/-o32/-n32/-green/-native is at the beginning
  108. # of the argument list, override ABI and threads type based on that.  Also,
  109. # remove them from $@, because they are arguments _only_ to this wrapper.
  110. # These are alternatives to setting SGI_ABI or THREADS_FLAG.
  111. #
  112. for a in "$@"; do
  113.     case $a in
  114.     -native)
  115.         THREADS_TYPE=native_threads
  116.         shift
  117.         ;;
  118.     -green)
  119.         THREADS_TYPE=green_threads
  120.         shift
  121.         ;;
  122.     -32)
  123.         JAVA_N32=0
  124.         shift
  125.         ;;
  126.     -o32)
  127.         JAVA_N32=0
  128.         shift
  129.         ;;
  130.     -n32)
  131.         JAVA_N32=1
  132.         shift
  133.         ;;
  134.     *)
  135.         break
  136.         ;;
  137.     esac
  138. done
  139.  
  140. if [ -z "$JAVA_HOME" ] ; then
  141.     export JAVA_HOME
  142.     JAVA_HOME=$J_HOME
  143. fi
  144.  
  145. #
  146. # For some programs like appletviewer, it is important that "." not be
  147. # in the classpath by default (unless the user set the CLASSPATH
  148. # explicitly). Applications that fit in this list are ones that load
  149. # classes through a ClassLoader, where classes coming off . will end
  150. # up being system classes. For now we know of only appletviewer.
  151. #
  152. NO_DOT_LIST="appletviewer"
  153. DEFAULT_CLASSPATH="."
  154. for excluded in ${NO_DOT_LIST}; do
  155.     if [ ${excluded} = ${progname} ]; then
  156.         DEFAULT_CLASSPATH="";
  157.     fi
  158. done
  159.  
  160. CLASSPATH="${CLASSPATH:-${DEFAULT_CLASSPATH}}"
  161. check_path $CLASSPATH "CLASSPATH"
  162. COMM_CLASSPATH="$JAVA_HOME/classes:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/i18n.jar:$JAVA_HOME/lib/classes.zip"
  163.  
  164. if [ -z "${CLASSPATH}" ] ; then
  165.     CLASSPATH=$COMM_CLASSPATH
  166. else
  167.     CLASSPATH="$CLASSPATH:$COMM_CLASSPATH"
  168. fi
  169.  
  170. export CLASSPATH
  171.  
  172. if [ $JAVA_N32 = 1 ]
  173. then
  174.   check_path $LD_LIBRARYN32_PATH "LD_LIBRARYN32_PATH"
  175.   if [ -z "$LD_LIBRARYN32_PATH" ]
  176.   then
  177.     if [ -z "$LD_LIBRARY_PATH" ]
  178.     then
  179.       LD_LIBRARYN32_PATH=$JAVA_HOME/lib32/sgi/$THREADS_TYPE
  180.     else
  181.       check_path $LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  182.       LD_LIBRARYN32_PATH="$JAVA_HOME/lib32/sgi/$THREADS_TYPE:$LD_LIBRARY_PATH"
  183.     fi
  184.   else
  185.     LD_LIBRARYN32_PATH="$JAVA_HOME/lib32/sgi/$THREADS_TYPE:$LD_LIBRARYN32_PATH"
  186.   fi
  187.   export LD_LIBRARYN32_PATH
  188.   prog=$JAVA_HOME/bin32/sgi/${THREADS_TYPE}/${progname}
  189. else
  190.   check_path $LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  191.   if [ -z "$LD_LIBRARY_PATH" ]
  192.   then
  193.     LD_LIBRARY_PATH=$JAVA_HOME/lib/sgi/$THREADS_TYPE
  194.   else
  195.     LD_LIBRARY_PATH="$JAVA_HOME/lib/sgi/$THREADS_TYPE:$LD_LIBRARY_PATH"
  196.   fi
  197.   export LD_LIBRARY_PATH
  198.   prog=$JAVA_HOME/bin/sgi/${THREADS_TYPE}/${progname}
  199. fi
  200.  
  201. XFILESEARCHPATH="$JAVA_HOME/lib/locale/%L/%T/%N%S:$XFILESEARCHPATH"
  202. export XFILESEARCHPATH
  203.  
  204. if [ -f $prog ]
  205. then
  206.      exec $DEBUG_PROG $prog $opts "$@"
  207. else
  208.     echo >&2 "$progname was not found in ${prog}"
  209.     if [ $JAVA_N32 = 1 ] ; then
  210.     ABI_STRING="n32"
  211.     SUBSYSTEM_STRING_1="sw32"
  212.     else
  213.     ABI_STRING="o32"
  214.     SUBSYSTEM_STRING_1="sw"
  215.     fi
  216.     if [ $THREADS_TYPE = "green_threads" ] ; then
  217.     THREADS_STRING="green-threads"
  218.     SUBSYSTEM_STRING_2="binaries"
  219.     else
  220.     THREADS_STRING="native-threads"
  221.     SUBSYSTEM_STRING_2="native"
  222.     fi
  223.     echo >&2 "For $ABI_STRING $THREADS_STRING tools, install java_{eoe,dev}.$SUBSYSTEM_STRING_1.$SUBSYSTEM_STRING_2 subsystems"
  224.     exit 1
  225. fi
  226.